// 新版本merge使用require导入需要解构
const { merge } = require('webpack-merge')
const common = require('./webpack.common')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')

module.exports = merge(common, {
    mode: 'production',
    plugins: [
        // 清除输出文件目录
        new CleanWebpackPlugin(),
        // 复制静态文件目录至输出目录
        // 新版本CopyWebpackPlugin配置有所改动
        new CopyWebpackPlugin({
            patterns: [
                // 复制的目录名称  输出的目录名称
                { from: 'public/favicon.ico', to: 'public/favicon.ico'}
            ]
        })
    ]
})